
package my.algorithms.mcorrea.java.test;

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.security.Key;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
/**
 *
 * @author mcorrea
 */
public class Crypto {

	private static final byte[] keybytes = new byte[] { (byte) 0xfc, (byte) 0x4f, (byte) 0xbe, (byte) 0x23,
	(byte) 0x59, (byte) 0xf2, (byte) 0x42, (byte) 0x37, (byte) 0x4c, (byte) 0x80, (byte) 0x44, (byte) 0x31,
	(byte) 0x20, (byte) 0xda, (byte) 0x20, (byte) 0x0c };
	
	public static void main(String args[])throws Exception{
		String encode = Base64.encode(new String("Manuel Correa").getBytes());
		System.out.println(encode);
		
		System.out.println( new String( Base64.decode(encode))  );
	
		Mac mac = Mac.getInstance("HMACSHA1");
		Key key = new SecretKeySpec(keybytes, "HMACSHA1");
		mac.init(key);
		byte[] hashValue = mac.doFinal("The lady doth protest too much, methinks".getBytes());
		String encodedHashValue = Base64.encode(hashValue);
		System.out.println(encodedHashValue);
		
		
		
		
	}
	

	
}
